<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>当前要事v1</title>
    <meta
      name="description"
      content="记录和提醒当前最重要的事，可以设置为浏览器起始页tab"
    />
    <style>
      body {
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
        background-image: url("./img/bg1.webp");
        background-size: cover;
        background-position: center center;
        background-repeat: no-repeat;
      }
      .box {
        display: flex;
        align-items: center;
        justify-content: center;
      }
      #shuRuKuang {
        border: 0;
        border-bottom: 2px solid #fff;
        padding: 4px 2px;
        display: block;
        background: 0;
        line-height: 1.5;
        outline: none;
        text-align: center;
        transition: border-color 0.2s ease-in-out;
        border-radius: 0;
        color: #fff;
        font-size: 2rem;
        max-width: 90%;
      }

      #anNiu {
        margin-left: -30px;
        margin-right: 10px;
        color: #ccc;
        border-radius: 50%;
        height: 40px;
        width: 40px;
        text-align: center;
        line-height: 30px;
        cursor: pointer;
      }

      input::placeholder {
        color: #ccc;
      }
      input::-webkit-input-placeholder {
        color: #ccc;
      }
    </style>
  </head>

  <body>
    <div class="box">
      <input placeholder="最重要的事？" id="shuRuKuang" />
      <span id="anNiu" onclick="change()">✔</span>
    </div>
    <script>
      let youShi = false;

      function change() {
        let anNiu = document.getElementById("anNiu");
        let shuRuKuang = document.getElementById("shuRuKuang");

        if (youShi) {
          youShi = false;
          anNiu.innerText = "✔";
          shuRuKuang.style.borderBottomColor = "#fff";
          shuRuKuang.value = "";
          shuRuKuang.readOnly = false;
          window.localStorage.removeItem("shi");
        } else {
          youShi = true;
          anNiu.innerText = "✘";
          shuRuKuang.style.borderBottomColor = "transparent";
          shuRuKuang.readOnly = true;
          window.localStorage.setItem("shi", shuRuKuang.value);
        }
      }

      let data = window.localStorage.getItem("shi");
      if (data) {
        document.getElementById("shuRuKuang").value = data;
        change();
      }
    </script>
  </body>
</html>
